分类目录归档:未分类

京东商城技术揭秘:.NET与Java博弈

春运期间,铁道部的现任老大12306网站在面对日均10亿多次的点击量时,频繁瘫痪,给我们带来的惨痛教训是,关键时刻掉不能掉链子,这也印证了科技是第一生产力。

而说起中国自主经营式B2C网站的行业老大,京东商城在2011年第三季度京东商城创下了37.8%的市场占有率。2011年6月18日,京东商城6周年店庆当天订单量接近50万单、单日销售额超过2亿元,在中国电子商务市场创下单日销售量历史纪录。那么,面临如此大规模并发访问压力,京东商城采取了何种技术架构的B2C系统来支撑其运营呢?

前端采用.NET技术架构

说起京东商城,不得不提到它的掌门人,2011CCTV十大经济人物“刘强东”。刘强东毕业于中国人民大学,理科超强的他业余时间自学编程。在创立京东商城的早期,刘强东选用了最为熟悉的.NET,直到现在,京东商城的前端部分仍然沿用.NET技术架构。

后端采用Java技术

京东商城连续六年200%以上的增长率,并不能掩盖其背后隐含的技术难题。比如,在2011年11月1日京东商城的图书促销活动中,由于促销活动仅限时1个小时,消费者疯狂抢购导致服务器不堪重负,最终瘫痪。为平息消费者的抱怨,刘强东在微博上表示:“重搞活动,增加3倍服务器,活动时间不能低于3小时。”尽管刘强东的危机公关做得很到位,即使京东商城增加了三倍服务器,技术问题依旧没有解决。

随后京东商城进行了技术构架调整,基于历史原因前端技术依然使用.NET技术开发并且进行了大规模的性能优化,将系统后台使用JAVA技术进行重构,暂时性的缓解了系统访问压力。

据最新消息,京东商城已经投入了大量资金邀请国外的咨询公司做技术策略顾问,并开始大规模招聘JAVA研发人员,这一点从京东商城的“人才招聘”页面就可以看出。预计在未来不久京东商城将全面切换至JAVA架构了。

团购采用PHP技术

据团购导航网站团800最新统计,2011年国内团购市场交易总额达110亿元,比2010年实现了550%的增长;超过3亿人次“抱团”消费,而按全年平均折扣3.6折计算,团购为全国消费者共节省了超过190亿元的消费支出,比2010年多省了156亿元。

看看上述这组数字,就不难想象京东商城对于团购的蛋糕是多么的垂涎欲滴。与众多团购网站一样,京东商城的团购频道采用了高效率的PHP技术。与其它语言相比,PHP是将程序嵌入到HTML文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;与同样是嵌入HTML文档的脚本语言JavaScript相比,PHP在服务器端执行,充分利用了服务器的性能;PHP执行引擎还会将用户经常访问的PHP程序驻留在内存中,其他用户在一次访问这个程序时就不需要重新编译程序了,只要直接执行内存中的代码就可以了,这也是PHP高效率的体现之一。PHP具有非常强大的功能,所有的CGI或者JavaScript的功能PHP都能实现,而且支持几乎所有流行的数据库以及操作系统。

UI采用jQuery插件

习惯网购的朋友都深有体会。大部分皇冠级淘宝卖家都是图片控。京东商城的放大图效果也是吸引消费者的法宝之一。京东商城产品展示页支持多图切换并放大代码,放大功能的核心代码为jQzoom,当把鼠标移到下边的小图上的时候,上边显示大图片,当把鼠标放到大图片上,右侧则出现鼠标对应地方的大图片,方便查看产品细节,比较适合网店产品展示。

JQZoom 是一个JavaScript图像放大镜,内置在流行的jQuery JavaScript框架顶部。jQzoom 功能非常强大,操作较为简单。支持标准模式、反转模式、无镜头、无标题的放大,并可以自定义jQZoom的窗口位置和渐隐效果,更多信息,请查看http://tech.it168.com/a2012/0112/1302/000001302122.shtml。

今日,京东商城高调宣布招聘2万人。笔者查看了一下京东商城招聘页面,发现很多研发职位。这也从侧面回击了专业人士关于“京东商城大手笔在抢购市场上烧钱,但其物流和后台系统技术上却没有跟上脚步”的质疑。

15秒快速购买火车票教程:

1、提前十五分钟(8点放票,我是7点半登的系统),用Firefox(8.01)打开页面:https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init

2、提前十分钟,查询能够进入预订页面(预订按钮为激活状态)的同类车次,进入该页面。比如,我想订的是14号T9的硬卧(这个时候还没放出来),但我知道12号的硬座还有票,那么我直接查询12号T9。

1325736318_00128300

3、提前五分钟,用Firebug改好相应的参数,这步非常重要。

3A、修改席别

右键单击 席别 下面的下拉列表,选择 审查元素。

1325736318_82028600

修改 硬座 对应项的值,即将 Value 改为3(3对应的是硬卧)。

 

1325736322_81302700

3B、修改日期

在之前动态修改的 HTML 代码之上,找到 id 为 start_date 的 INPUT 标记(默认为隐藏),将日期修改为想要预定的时间。

.1325736323_82592200

4、提前一分钟,单击(刷新)验证码并填好(注意是只刷新验证码)。

5、提前几秒钟,单击提交订单按钮

mp3 frame header


AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM

Sign Length
(bits)
Position
(bits)
Description
A 11 (31-21) Frame sync (all bits must be set)
B 2 (20,19) MPEG Audio version ID
00 – MPEG Version 2.5 (later extension of MPEG 2)
01 – reserved
10 – MPEG Version 2 (ISO/IEC 13818-3)
11 – MPEG Version 1 (ISO/IEC 11172-3)

Note: MPEG Version 2.5 was added lately to the MPEG 2 standard.
It is an extension used for very low bitrate files, allowing
the use of lower sampling frequencies. If your decoder does
not support this extension, it is recommended for you to use
12 bits for synchronization instead of 11 bits.

C 2 (18,17) Layer description
00 – reserved
01 – Layer III
10 – Layer II
11 – Layer I
D 1 (16) Protection bit
0 – Protected by CRC (16bit CRC follows header)
1 – Not protected
E 4 (15,12) Bitrate index

bits V1,L1 V1,L2 V1,L3 V2,L1 V2, L2 & L3
0000 free free free free free
0001 32 32 32 32 8
0010 64 48 40 48 16
0011 96 56 48 56 24
0100 128 64 56 64 32
0101 160 80 64 80 40
0110 192 96 80 96 48
0111 224 112 96 112 56
1000 256 128 112 128 64
1001 288 160 128 144 80
1010 320 192 160 160 96
1011 352 224 192 176 112
1100 384 256 224 192 128
1101 416 320 256 224 144
1110 448 384 320 256 160
1111 bad bad bad bad bad

NOTES: All values are in kbps
V1 – MPEG Version 1
V2 – MPEG Version 2 and Version 2.5
L1 – Layer I
L2 – Layer II
L3 – Layer III

“free” means free format. The free bitrate must
remain constant, an must be lower than the maximum allowed
bitrate. Decoders are not required to support decoding of
free bitrate streams.
“bad” means that the value is unallowed.

MPEG files may feature variable bitrate (VBR). Each frame
may then be created with a different bitrate. It may be used
in all layers. Layer III decoders must support this method.
Layer I & II decoders may support it.

For Layer II there are some combinations of bitrate and mode
which are not allowed. Here is a list of allowed combinations.

bitrate
single channel
stereo
intensity stereo
dual channel
free
yes
yes
yes
yes
32
yes
no
no
no
48
yes
no
no
no
56
yes
no
no
no
64
yes
yes
yes
yes
80
yes
no
no
no
96
yes
yes
yes
yes
112
yes
yes
yes
yes
128
yes
yes
yes
yes
160
yes
yes
yes
yes
192
yes
yes
yes
yes
224
no
yes
yes
yes
256
no
yes
yes
yes
320
no
yes
yes
yes
384
no
yes
yes
yes
F 2 (11,10) Sampling rate frequency index

bits MPEG1 MPEG2 MPEG2.5
00 44100 Hz 22050 Hz 11025 Hz
01 48000 Hz 24000 Hz 12000 Hz
10 32000 Hz 16000 Hz 8000 Hz
11 reserv. reserv. reserv.
G 1 (9) Padding bit
0 – frame is not padded
1 – frame is padded with one extra slot

Padding is used to exactly fit the bitrate.As an example: 128kbps
44.1kHz layer II uses a lot of 418 bytes and some of 417 bytes
long frames to get the exact 128k bitrate. For Layer I slot
is 32 bits long, for Layer II and Layer III slot is 8 bits long.

H 1 (8) Private bit. This one is only informative.
I 2 (7,6) Channel Mode
00 – Stereo
01 – Joint stereo (Stereo)
10 – Dual channel (2 mono channels)
11 – Single channel (Mono)

Note: Dual channel files are made of two independant mono channel.
Each one uses exactly half the bitrate of the file. Most decoders
output them as stereo, but it might not always be the case.
    One example of use would be some speech
in two different languages carried in the same bitstream, and
then an appropriate decoder would decode only the choosen language.

J 2 (5,4) Mode extension (Only used in Joint stereo)

Mode extension is used to join informations that are of no
use for stereo effect, thus reducing needed bits. These bits
are dynamically determined by an encoder in Joint stereo mode,
and Joint Stereo can be changed from one frame to another,
or even switched on or off.

Complete frequency range of MPEG file is divided in subbands
There are 32 subbands. For Layer I & II these two bits determine
frequency range (bands) where intensity stereo is applied.
For Layer III these two bits determine which type of joint
stereo is used (intensity stereo or m/s stereo). Frequency
range is determined within decompression algorithm.

Layer I and II Layer III
value Layer I & II
00 bands 4 to 31
01 bands 8 to 31
10 bands 12 to 31
11 bands 16 to 31
Intensity stereo MS stereo
off off
on off
off on
on on
K 1 (3) Copyright
0 – Audio is not copyrighted
1 – Audio is copyrighted

The copyright has the same meaning as the copyright bit on CDs
and DAT tapes, i.e. telling that it is illegal to copy the contents
if the bit is set.

L 1 (2) Original
0 – Copy of original media
1 – Original media

The original bit indicates, if it is set, that the frame is
located on its original media.

M 2 (1,0) Emphasis
00 – none
01 – 50/15 ms
10 – reserved
11 – CCIT J.17

The emphasis indication is here to tell the decoder that the
file must be de-emphasized, ie the decoder must ‘re-equalize’
the sound after a Dolby-like noise supression. It is rarely
used.

关于Linux下C/C++程序编译

在编译之前我们需要在系统里安装G++ GCC,它们就是Linux下的C++/C的编译器。代码如下
代码:

sudo apt-get install build-essential

好,现在我们在文本编辑器里写一个C的简单的程序(好像所有学习C或者C++的书都会出现)
代码:

#include <stdio.h>
int main()
{
printf("Hello,World!n");
return 0;
}

现在存盘为Hello.c,打开你的终端,并在文件当前目录输入:
代码:

gcc Hello.c -o hello   

编译时可能会出现如下警告:no newline at and of file ,只有在文件结尾添加一个新行就好了。
然后在终端中输入 ./hello ,你就能在终端中看到程序运行结果了。

下面来说下C++是如何编译的
写程序(不用我多说了吧)
代码:

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello,World!n"<<endl;
return 0;
}

存盘为Hello.cpp
使用gcc编译??? 不对,这里我们使用g++来编译C++程序
代码:

g++ Hello.cpp -o hello

编译多个文件我们怎么办??? 来看下面出了三个文件Hello.h, Hello.cpp, MyFirst.cpp
代码:

//file_NO1:Hello.h
class Hello {
Hello();
void Display();
}
//file_NO2:Hello.cpp
#include <iostream>
#include "Hello.h"
using namespace std;
Hello::Hello()
{
}
Hello::Display()
{
cout<<"Hello,World!n"<<endl;
}
//file_NO3:MyFirst.cpp
#include <iostram>
#include "Hello.cpp"
int main()
{
Hello theHello;
theHello->Display();
return 0;
}

在g++中有一个参数-c 可以只编译不连接,那么我们就可以按如下顺序编译文件,
代码:

g++ -c Hello.cpp -o Hello.o
g++ -c MyFirst.cpp -o MyFirst.o
g++ MyFirst.o hello.o -o MyFirst

你是否会问,如果是一个项目的话,可能会有上百个文件,这样的编译法,人不是要累死在电脑前吗,或者等到你编译成功了,岂不是头发都白了,呵呵,所以我们要把上述的编译过程写进以下一个文本文件中:
Linux下称之为makefile
[code]
#这里可以写一些文件的说明
MyFirst: MyFirst.o hello.o
g++ MyFirst.o hello.o -o MyFirst
Hello.o:Hello.cpp
g++ -c Hello.cpp -o Hello.o
MyFirst.o:MyFirst.cpp
g++ -c MyFirst.cpp -o MyFirst.o
[code]
存盘为MyFirst,在终端输入:make MyFist ,程序出现了错误可是所有程序员共同的敌人,在编写程序时我们应该尽量的去避免错误 的出现,不过编写的时候再怎么都不可避免的出现这样那样的错误,对程序进行必要的调试是一个好主意,那我们怎么来调试程序呢,看下面:
[code]
gdb ./文件名
[/code]
以下为调试状态下的可以用到的命令(可以仅输入单词的输入,如break可简为b),尖括号中为说明
[code]
list <显示源代码>
break 行号 <设置断点>
run <运行程序>
continue <继续从断点处执行>
print 变量 <调试时查看变量的值>
del 行号 <删除断点>
step <单步执行,可跟踪到函数内部>
next <单步执行,不可跟踪到函数内部>
quit <退出>
[/code]

test

<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
version: 2,
type: ‘profile’,
rpp: 4,
interval: 6000,
width: 250,
height: 300,
theme: {
shell: {
background: ‘#333333’,
color: ‘#ffffff’
},
tweets: {
background: ‘#000000’,
color: ‘#ffffff’,
links: ‘#4aed05’
}
},
features: {
scrollbar: false,
loop: false,
live: false,
hashtags: false,
timestamp: false,
avatars: false,
behavior: ‘all’
}
}).render().setUser(‘sheng00’).start();
</script>

bit与byte的区别

Bit意为“位”或“比特”,是计算机运算的基础,属于二进制的范筹;
Byte意为“字节”,是计算机文件大小的基本计算单位; 
这两者应用的场合不同。通常用bit来作数据传输的单位,因为物理层,数据链路层的传输对于用户是透明的,而这种通信传输是基于二进制的传输。在应 用层通常是用byte来作单位,表示文件的大小,在用户看来就是可见的数据大小。比如一个字符就是1byte,如果是汉字,则是2byte。
下面是2个具体应用实例:
Mbps=mega bits per second(兆位/秒)是速率单位,
MB=mega bytes(兆比、兆字节)是量单位,1MB/S(兆字节/秒)=8MBPS(兆位/秒)。
我们所说的硬盘容量是40GB、80GB、100GB,这里的B指是的Byte也就是“字节”。(与容量相关,应用层)
1 KB = 1024 bytes =2^10 bytes
1 MB = 1024 KB = 2^20 bytes
1 GB = 1024 MB = 2^30 bytes
USB2.0标准接口传输速率是480兆位/秒,即480MBps。这里的B指是的Bit也就是“位”。(与传输相关,底层)

注:另外,Byte通常简写为B(大写),而bit通常简写为b(小写)。可以这么记忆,用大写的就是数据值比较大的位,而小字的就是数据值比较小的字节,1B=8b。

java基础类型知识

Java 提供两种不同的类型:引用类型和原始类型(或内置类型)。Int是java的原始数据类型,Integer是java为int提供的封装类。Java为每个原始类型提供了封装类。
原始类型封装类
boolean –>Boolean
char —>Character
byte –>Byte
short –>Short
int –>Integer
long –>Long
float –>Float
double –>Double
引用类型和原始类型的行为完全不同,并且它们具有不同的语义。引用类型和原始类型具有不同的特征和用法,它们包括:大小和速度问题,这种类型以哪种类型的 数据结构存储,当引用类型和原始类型用作某个类的实例数据时所指定的缺省值。对象引用实例变量的缺省值为 null,而原始类型实例变量的缺省值与它们的类型有关。同时为了面向对象操作的一致性,这些基本类型都有相应的封装类型:Integer、Short、 Long、Byte、Float、Double、Character等。      
因为封装类型是对象,所以可以进行相应的很多对象能力函数操作,这样就可以提供很多基本类型难以完成的工作的完成和实现。   
你可以通过以下方式来声明该类型。

int a,a为int类型的变量
char a,a为char类型的

String对象

1. 首先String不属于8种基本数据类型,String是一个对象。

  因为对象的默认值是null,所以String的默认值也是null;但它又是一种特殊的对象,有其它对象没有的一些特性。

  2. new String()和new String(“”)都是申明一个新的空字符串,是空串不是null;

  3. String str=”punkll”;

   String str=new String (“punkll”);的区别:

  在这里,我们不谈堆,也不谈栈,只先简单引入常量池这个简单的概念。

  常量池(constant pool)指的是在编译期被确定,并被保存在已编译的.class文件中的一些数据。它包括了关于类、方法、接口等中的常量,也包括字符串常量。

  看例1:

  String s0=”punkll”;

  String s1=”punkll”;

  String s2=”punk” + “ll”;

  System.out.println( s0==s1 );

  System.out.println( s0==s2 );

  结果为:

  true

  true

  首先,我们要知结果为道Java会确保一个字符串常量只有一个拷贝。

  因为例子中的s0和s1中的”punkll”都是字符串常量,它们在编译期就被确定了,所以s0==s1为true;而”punk”和”ll” 也都是字符串常量,当一个字符串由多个字符串常量连接而成时,它自己肯定也是字符串常量,所以s2也同样在编译期就被解析为一个字符串常量,所以s2也是 常量池中”punkll”的一个引用。

  所以我们得出s0==s1==s2;

  用new String() 创建的字符串不是常量,不能在编译期就确定,所以new String() 创建的字符串不放入常量池中,它们有自己的地址空间。

  看例2:

  String s0=”punkll”;

  String s1=new String(”punkll”);

  String s2=”punk” + new String(“ll”);

  System.out.println( s0==s1 );

  System.out.println( s0==s2 );

  System.out.println( s1==s2 );

  结果为:

  false

  false

  false

  例2中s0还是常量池中”punkll”的应用,s1因为无法在编译期确定,所以是运行时创建的新对象”punkll”的引用,s2因为有后半 部分new String(“ll”)所以也无法在编译期确定,所以也是一个新创建对象”punkll”的应用;明白了这些也就知道为何得出此结果了。